new Vue({
    el: '#app',
    data() {
        return {
            html: '',
            options: [{
                value: 0,
                label: '用户服务协议'
            }, {
                value: 1,
                label: '隐私协议'
            }, {
                value: 2,
                label: '用户授权协议'
            }],
            form: {
                Reptile_config_SerialNumber: '',
                Reptile_Config_URL: "http://www.agri.cn/xxh/",
                Reptile_Config_ClassName: '.trends_right .trends_list ul li a',
                Reptile_Config_Quantity: 4,
                Reptile_Config_SetInterval: 6000,
            }
        }
    },
    mounted() {
    },
    methods: {
        back() {
            window.history.go(-1)
        },
        subMessage() {
            if (this.form.Reptile_Config_URL == '') {
                this.$message.error("请输入爬取地址")
                return
            }
            if (this.form.Reptile_Config_ClassName == '') {
                this.$message.error("请输入爬取样式")
                return
            }
            if (this.form.Reptile_Config_Quantity == '') {
                this.$message.error("请输入爬取区域次数")
                return
            }
            if (this.form.Reptile_Config_SetInterval == '') {
                this.$message.error("请输入爬取定时器间隔")
                return
            }
            if(this.form.Reptile_Config_SetInterval<6000){
                this.$message.error("爬取定时器间隔时间太短")
                return
            }
            if(this.form.Reptile_Config_SetInterval>360000){
                this.$message.error("爬取定时器间隔时间太长")
                return
            }
            const _this = this
            console.log(this.form)
            let data = {
                Data: JSON.stringify({ "reptile_config": [this.form] }),
            }
            $.ajax({
                url: DomainName + '/getAddAction?token=' + $.cookie('token'),
                type: 'POST',
                data,
                success: function (res) {
                    console.log('提交结果', res)
                    if (res.Status == 'success') {
                        _this.$message.success("成功!")
                        window.history.go(-1)
                    }
                },
                error: function () {
                    _this.$message.error("操作失败，请稍后再试")
                },
                complete: function (XMLHttpRequest) {
                    _this.loading = false
                    if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
                        window.parent.document.location.href = "../../../" + XMLHttpRequest.getResponseHeader("CONTENTPATH");
                    }
                }
            })
        }
    },
})